import React, { Component } from 'react';
import '../styles/Address.scss'
import * as service from '../api/index'
import { NavBar, Button } from 'antd-mobile'
import { EditSOutline } from 'antd-mobile-icons'

class Address extends Component {
    state = {
        addresslist: []
    }
    async componentDidMount() {
        let res = await service.mine_address()
        // console.log(res.data.list);
        this.setState({ addresslist: res.data.list })
    }
    back = () => {
        this.props.history.goBack()
    }
    render() {
        return (
            <div className='address'>
                <NavBar onBack={() => { this.back() }}>地址管理</NavBar>
                <div className="addresslist">
                    {
                        this.state.addresslist.map((item, index) => {
                            return (
                                <div className="item">
                                    <div className="text">

                                        <div className="name_phone">
                                            <div className="name">
                                                {item.name}
                                            </div>
                                            <div className="phone">
                                                {item.phone}
                                            </div>
                                        </div>
                                        <div className="addr">
                                            收货地址：{item.addr}
                                        </div>
                                    </div>
                                    <div className="emit">
                                        <EditSOutline fontSize={18} />
                                    </div>
                                </div>
                            )
                        })
                    }

                </div>
                <div className="create">
                    <Button block color='danger' size='large'>
                        新建地址
                    </Button>
                </div>
            </div>
        );
    }
}

export default Address; 